<?php

declare(strict_types=1);

use Monolog\Handler;
use Monolog\Formatter;
use Monolog\Logger;




//return [
//    'default' => [
//        'handler' => [
//            'class' => \Monolog\Handler\StreamHandler::class,
//            'constructor' => [
//                'stream' => BASE_PATH . '/runtime/logs/hyperf.log',
//                'level' => \Monolog\Logger::ERROR,
//            ],
//        ],
//        'formatter' => [
//            'class' => \Monolog\Formatter\LineFormatter::class,
//            'constructor' => [
//                'format' => null,
//                'dateFormat' => null,
//                'allowInlineLineBreaks' => true,
//            ]
//        ],
//    ],
//];

$appEnv = env('APP_ENV', 'dev');
if ($appEnv == 'dev') {
    return [
        'default' => [
            'handler' => [
                'class' => \Monolog\Handler\StreamHandler::class,
                'constructor' => [
                    'stream' => 'php://stdout',
                    'level' => \Monolog\Logger::INFO,
                ],
            ],
            'formatter' => [
                'class' => \Monolog\Formatter\LineFormatter::class,
                'constructor' => [
                    'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                    'allowInlineLineBreaks' => true,
                    'includeStacktraces' => true,
                ],
            ],
        ],
        'file' => [
            'handler' => [
                'class' => Monolog\Handler\RotatingFileHandler::class,
                'constructor' => [
                    'filename' => BASE_PATH . '/runtime/logs/dev.log',
                    'level' => \Monolog\Logger::INFO,
                ],
            ],
            'formatter' =>[
                'class' => Formatter\JsonFormatter::class,
                'constructor' => [
                    'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                    'allowInlineLineBreaks' => true,
                    'includeStacktraces' => true,
                ],
            ],
        ],
        //订单日志
        'order'=>[
            'handlers' => [
                [
                    'class' => Monolog\Handler\RotatingFileHandler::class,
                    'constructor' => [
                        'filename' => BASE_PATH . '/runtime/logs/order-info.log',
                        'level' => Logger::INFO,
                    ],
                    'formatter' => [
                        'class' => Formatter\JsonFormatter::class,
                        'constructor' => [
                            'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                            'allowInlineLineBreaks' => true,
                            'includeStacktraces' => true,
                        ],
                    ],
                ],
                [
                    'class' => Monolog\Handler\RotatingFileHandler::class,
                    'constructor' => [
                        'filename' => BASE_PATH . '/runtime/logs/order-debug.log',
                        'level' => Logger::DEBUG,
                    ],
                    'formatter' => [
                        'class' => Formatter\JsonFormatter::class,
                        'constructor' => [
                            'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                            'allowInlineLineBreaks' => true,
                            'includeStacktraces' => true,
                        ],
                    ],
                ],
                [
                    'class' => Monolog\Handler\RotatingFileHandler::class,
                    'constructor' => [
                        'filename' => BASE_PATH . '/runtime/logs/order-error.log',
                        'level' => Logger::ERROR,
                    ],
                    'formatter' => [
                        'class' => Formatter\JsonFormatter::class,
                        'constructor' => [
                            'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                            'allowInlineLineBreaks' => true,
                            'includeStacktraces' => true,
                        ],
                    ],
                ],
            ],
        ]
    ];
} else {

    return [
        'default' => [
            'handlers' => [
                [
                    'class' => Monolog\Handler\RotatingFileHandler::class,
                    'constructor' => [
                        'filename' => BASE_PATH . '/runtime/logs/hyperf-info.log',
                        'level' => Logger::INFO,
                    ],
                    'formatter' => [
                        'class' => Formatter\JsonFormatter::class,
                        'constructor' => [
                            'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                            'allowInlineLineBreaks' => true,
                            'includeStacktraces' => true,
                        ],
                    ],
                ],
                [
                    'class' => Monolog\Handler\RotatingFileHandler::class,
                    'constructor' => [
                        'filename' => BASE_PATH . '/runtime/logs/hyperf-debug.log',
                        'level' => Logger::DEBUG,
                    ],
                    'formatter' => [
                        'class' => Formatter\JsonFormatter::class,
                        'constructor' => [
                            'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                            'allowInlineLineBreaks' => true,
                            'includeStacktraces' => true,
                        ],
                    ],
                ],
                [
                    'class' => Monolog\Handler\RotatingFileHandler::class,
                    'constructor' => [
                        'filename' => BASE_PATH . '/runtime/logs/hyperf-error.log',
                        'level' => Logger::ERROR,
                    ],
                    'formatter' => [
                        'class' => Formatter\JsonFormatter::class,
                        'constructor' => [
                            'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                            'allowInlineLineBreaks' => true,
                            'includeStacktraces' => true,
                        ],
                    ],
                ],
            ],
        ],

        'order'=>[
            'handlers' => [
                [
                    'class' => Monolog\Handler\RotatingFileHandler::class,
                    'constructor' => [
                        'filename' => BASE_PATH . '/runtime/logs/order-info.log',
                        'level' => Logger::INFO,
                    ],
                    'formatter' => [
                        'class' => Formatter\JsonFormatter::class,
                        'constructor' => [
                            'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                            'allowInlineLineBreaks' => true,
                            'includeStacktraces' => true,
                        ],
                    ],
                ],
                [
                    'class' => Monolog\Handler\RotatingFileHandler::class,
                    'constructor' => [
                        'filename' => BASE_PATH . '/runtime/logs/order-debug.log',
                        'level' => Logger::DEBUG,
                    ],
                    'formatter' => [
                        'class' => Formatter\JsonFormatter::class,
                        'constructor' => [
                            'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                            'allowInlineLineBreaks' => true,
                            'includeStacktraces' => true,
                        ],
                    ],
                ],
                [
                    'class' => Monolog\Handler\RotatingFileHandler::class,
                    'constructor' => [
                        'filename' => BASE_PATH . '/runtime/logs/order-error.log',
                        'level' => Logger::ERROR,
                    ],
                    'formatter' => [
                        'class' => Formatter\JsonFormatter::class,
                        'constructor' => [
                            'format' => "||%datetime%||%channel%||%level_name%||%message%||%context%||%extra%\n",
                            'allowInlineLineBreaks' => true,
                            'includeStacktraces' => true,
                        ],
                    ],
                ],
            ],
        ]

    ];
}
